#include<stdio.h>
#include<iostream>
using namespace std;

typedef struct LNode{
	char data;
	struct LNode *next;
}LNode, *LinkList;

void CreateList_H(LinkList &L){
	int length;
	puts("请输出字符个数：");
	cin>>length;
	L = new LNode;
	L->next = NULL;
	LNode *p = L;
	for(int i=1; i<=length; i++){
		LNode *s = new LNode;
		printf("请输入第%d个字符：", i);
		cin>>s->data;
		s->next = p->next;
		p->next = s;
	}
}

void ReverseList(LinkList &L){
	LNode *r = L;
	while(r->next){
		r = r->next;
	}
	LNode *temp = r;
	while(temp != L->next){
		LNode *p = L;
		while(p->next != temp){
			p = p->next;
		}
		temp->next = p;
		temp = temp->next;
	}
	temp->next = NULL;
	L->next = r;
}

void DisputeList(LinkList L){
	LNode *p = L;
	while(p->next){
		p = p->next;
		cout<<p->data;
	}
	puts("");
}

int main(void)
{
	LinkList La;
	CreateList_H(La);
	printf("链表创建成功，对其遍历\n");
	DisputeList(La);
	ReverseList(La);
	printf("链表逆置之后，对其遍历\n");
	DisputeList(La);
	return 0; 
}

